package com.sdx.common.service;

import com.ibeetl.admin.core.service.BaseService;
import com.ibeetl.admin.core.util.PlatformException;
import com.sdx.common.dao.ResCloudFileDao;
import com.sdx.common.entity.ResCloudFile;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 云文件 Service
 */

@Service
@Transactional
public class ResCloudFileService extends BaseService<ResCloudFile>{

    @Resource
	private ResCloudFileDao resCloudFileDao;

    public PageQuery<ResCloudFile>queryByCondition(PageQuery query){
        PageQuery ret =  resCloudFileDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelResCloudFile(List<String> ids){
        try {
            resCloudFileDao.batchDelResCloudFileByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除云文件失败", e);
        }
    }

    public void insertResFile(String cloudType,String filePath,String fileUrl,String mediaType,String resClass) {
	    ResCloudFile resCloudFile = new ResCloudFile();
	    resCloudFile.setCloudType(cloudType);
	    resCloudFile.setFilePath(filePath);
	    resCloudFile.setFileUrl(fileUrl);
	    resCloudFile.setMediaType(mediaType);
	    resCloudFile.setResClass(resClass);
	    resCloudFileDao.insert(resCloudFile);
    }
	public List<ResCloudFile> all() {
		return resCloudFileDao.all();
		}
}